import { Navigate, useRoutes } from 'react-router-dom'
import MyLayout from '../pages/myLayout/myLayout'
import Login from '../pages/login/login'
import Order from '../pages/order/order'
import SiteOrder from '../pages/siteOrder/siteOrder'
import PutStore from '../pages/putStore/putStore'
const GetRouters = () => {
  const routes = useRoutes([
    {
      path: '/',
      element: (
        <Navigate
          to={localStorage.getItem('token') ? 'layout' : 'login'}></Navigate>
      ),
    },
    {
      path: '/layout',
      element: <MyLayout />,
      children: [
        {
          path: 'order',
          element: <Order></Order>,
          index: true,
        },
        {
          path: 'siteOrder',
          element: <SiteOrder></SiteOrder>,
        },
        {
          path: 'putOrder',
          element: <PutStore></PutStore>,
        },
      ],
    },
    {
      path: '/login',
      element: <Login></Login>,
    },
  ])
  return routes
}
export default GetRouters
